package org.cqut.system.work_submit.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.cqut.framework.utils.DateUtils;
import org.cqut.system.work_submit.domain.WorkSubmit;
import org.cqut.system.work_submit.service.WorkSubmitService;
import org.cqut.system.work_submit.mapper.WorkSubmitMapper;
import org.cqut.system.work_submit.vo.RecordListVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * @author XiAoXu
 */
@Service
public class WorkSubmitServiceImpl extends ServiceImpl<WorkSubmitMapper, WorkSubmit>
        implements WorkSubmitService {

    @Autowired
    private WorkSubmitMapper workSubmitMapper;

    @Override
    public List<RecordListVo> getRecordList(Map<String, Object> map) {
        return workSubmitMapper.selectRecordList((ArrayList<Integer>) map.get("ids"));
    }

    @Override
    public boolean saveGrade(WorkSubmit workSubmit) {
        workSubmit.setSubmitStatus("已阅");
        return updateById(workSubmit);
    }

    @Override
    public boolean saveSubmit(String path, String recordId) {
        WorkSubmit workSubmit = new WorkSubmit();
        workSubmit.setSubmitPath(path);
        workSubmit.setRecordId(Long.valueOf(recordId));
        workSubmit.setSubmitTime(DateUtils.formatDate(DateUtils.getNowDate()));
        return save(workSubmit);
    }
}




